added SSCLI 1.0
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2010 / VBASPNETPrintPartOfPage / ReadMe.txt
blob2591869bb7bb50a8dcded36a572258945edeb79b
1 ========================================================================
2                   VBASPNETPrintPartOfPage Overview
3 ========================================================================
5 /////////////////////////////////////////////////////////////////////////////
6 Use:
8 The project illustrates how to print a specific part of a page.
9 A web form page will contain many parts and some of them need not 
10 print for a page, such as button controls, you can not click them
11 in print page, So this sample provides a method to avoid print
12 needless part of page.
14 /////////////////////////////////////////////////////////////////////////////
15 Demo the Sample. 
17 Please follow these demonstration steps below.
19 Step 1: Open the VBASPNETPrintPartOfPage.sln.
21 Step 2: Expand the VBASPNETPrintPartOfPage web application and press 
22         Ctrl + F5 to show the Default.aspx.
24 Step 3: You will see many parts of Default.aspx page, There are one "print this
25         page" button and four CheckBoxes in the middle of page.
27 Step 4: Choose the CheckBox to select which part of the page you want to print
28         , then click the Button control to print current page. If you do not
29             have an available printer, Choose the MicroSoft XPS Document Writer to 
30                 test this sample. You can see the part of page print with .xps
31             file, except for the title of web page.
33 Step 5: Validation finished.
35 /////////////////////////////////////////////////////////////////////////////
36 Code Logical:
38 Step 1. Create a VB "ASP.NET Empty Web Application" in Visual Studio 2010 or
39         Visual Web Developer 2010. Name it as "VBASPNETPrintPartOfPage".
41 Step 2. Add a web form in the root direcory, named it as "Default.aspx".
43 Step 3. Add a "image" folder in the root direcory, add a picture you want 
44         display in page.
46 Step 4. Create some tables in Default.aspx,and you can fill them with html
47         elements such as image, text, control , etc. 
49 Step 5. Define some public strings to store html tag and deposite them in
50         Default.aspx page. 
51             [code]
52                     'define some stirngs,use to cut of html code
53             Public printImageBegin As String
54             Public printImageEnd As String
56                     'check the status of CheckBox,set div elements.
57             If CheckBox2.Checked Then
58                 printImageBegin = String.Empty
59                 printImageEnd = String.Empty
60             Else
61                 printImageBegin = enablePirnt
62                 printImageEnd = endDiv
63             End If
64                 [/code]
65          
66 Step 6. Use JavaScript code to print currently page depend on the status of
67         CheckBox, assign JavaScript function to button's onclick event.The
68                 css and js code:
69                 [code]
70                 <style type="text/css" media="print">  
71             .nonPrintable
72             {
73                display: none;
74             }
75         </style>
76         <script type="text/javascript">
77             function print_page() {
78                window.print();
79             }
80         </script>
81                 [/code]
83 Step 7. Build the application and you can debug it.
84 /////////////////////////////////////////////////////////////////////////////
85 References:
87 MSDN: window.print function
88 http://msdn.microsoft.com/en-us/library/ms536672(VS.85).aspx
90 MSDN: CSS Reference
91 http://msdn.microsoft.com/en-us/library/ms531209(VS.85).aspx
92 /////////////////////////////////////////////////////////////////////////////